let uu = document.querySelector("#info>ul")
let categoryid = getQueryString("categoryid")

    let select = document.querySelector("select")
    let prev = document.querySelector("button.prev")
    let next = document.querySelector("button.next")
    let nav_three = document.querySelector("nav>a:nth-child(3)")

    let container = document.querySelector('.container')
    //封装函数，页面动态创建li，正则 /(?<=imgurl=)[^'"]*/拼接img地址 
    // <img width="100" src="http://a.manmanbuy.com:8013/cuxiaoPic/201610/2016100012575382955.jpg" alt="">
    //<b>wenbenneirog</b>
    let domStr = "";
    function render(data, el) {
        console.log(data, el)
        let domStr = "";
        data.forEach(item => {
            domStr +=  `
            <li productId=${item.productId}>
                <a href="#">
                    <div class="img">
                        ${item.productImg}
                    </div>
                    <div class="infoR">
                        <div class="title">
                            <h4>${item.productName}</h4>
                            <div class="price">${item.productPrice}</div>
                        </div>
                        <div class="other">
                            <span class="take_price">${item.productQuote}</span>
                            <i>${item.productCom}</i>
                        </div>
                    </div>
                </a>
            </li>`
        })
        uu.innerHTML = domStr
    }
    //发起页面请求，获得数据
    function getData(pageid = 1) {
        fetch("http://chst.vip:1234/api/getproductlist?categoryid="+categoryid)
            .then(body => body.json())
            .then(res => {
                console.log(res)
                render(res.result,uu)
            })
    }
    getData()
    //改变pageid进行懒加载
    let pageid = 1;
    lazyLoad(function () {
        pageid++
        getData(pageid)
    }, 100)
    
        uu.addEventListener("click", function (e) {
            let _this = e.target;
            if (_this.className === "infoR") {
                productid = _this.parentNode.parentNode.getAttribute("productid")
                console.log(productid);
                location.href = "./bjsslists.html?productid=" + productid
            } else if (_this.localName === "img") {
                productid = _this.parentNode.parentNode.parentNode.getAttribute("productid")
                console.log(productid);
                location.href = "./bjsslists.html?productid=" + productid
            } else if (_this.localName === "h4" || _this.className === "price") {
                productid = _this.parentNode.parentNode.parentNode.parentNode.getAttribute("productid")
                console.log(productid);
                location.href = "./bjsslists.html?productid=" + productid
            } else if (_this.localName === "i" || _this.localName === "span") {
                productid = _this.parentNode.parentNode.parentNode.parentNode.getAttribute("productid")
                console.log(productid);
                location.href = "./bjsslists.html?productid=" + productid
            }
        }, true)
    
